/**
 * Copyright (C) 2013-2014 the original author or authors.
 */
package com.foreveross.bsl.common.utils.enums;

/**
 * @description
 *
 * @author rening
 * @version v1.0
 *
 * @2013-7-22
 *
 */
public enum AccountStatus {
	Auditing("a"),Inactive("i"),Disabled("d"),Suspended("s"),Normal("n");
	
	private String code;
	
	AccountStatus(String vlue){
		this.code = vlue;
	}
	
	public String getValue(){
		return this.code;
	}
	
	public String toString(){
		return this.code;
	}
	
	public static AccountStatus getByCode(String code){
		if(code == null){
			return null;
		}
		
		if("a".equals(code.toLowerCase())){
			return Auditing;
		} else if("i".equals(code.toLowerCase())){
			return Inactive;
		} else if("d".equals(code.toLowerCase())){
			return Disabled;
		} else if("s".equals(code.toLowerCase())){
			return Suspended;
		} else if("n".equals(code.toLowerCase())){
			return Normal;
		} else {
			return null;
		}
	}
	
	public static String getName(AccountStatus s){
		String name = null;
		switch (s) {
		case Auditing:
			name = "待审核";
			break;
		case Inactive:
			name = "未激活";
			break;
		case Disabled:
			name = "无效";
			break;
		case Suspended:
			name = "暂停";
			break;
		case Normal:
			name = "正常";
			break;
		default:
			name = "无效";
			break;
		}
		return name;
	}
}
